#include "bsp_uart.h"
//#include "SEGGER_RTT.h"


TxHandle_t htx1;
uint8_t txfifo1_buf[TXFIFO_LENGTH];
RxHandle_t hrx1;





void UART_BSP_Init(void)
{
	

	//创建接收句柄
	UART_RxHandle_CreateStatic(&huart1, &hrx1);

	//创建发送句柄
	UART_TxHandle_CreateStatic(&huart1, &htx1, txfifo1_buf, TXFIFO_LENGTH);

	//初始化串口
	User_USARTx_Init(&hrx1, 1);

}

/**
 * @brief  Tx Transfer completed callbacks.
 * @param  huart  Pointer to a UART_HandleTypeDef structure that contains
 *                the configuration information for the specified UART module.
 * @retval None
 */
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
{
	TxHandle_TxCpltCallback(&htx1);
}


void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size)
{
//	BaseType_t xHigherPriorityTaskWoken = pdFALSE;
	uint32_t ulValue;
	if (Size == 0) return;

	if(huart == hrx1.huart)
	{
		RxHandle_RxEventCallback(&hrx1, Size); //开启下一轮接收
		ulValue = 1<<0;
	}

	if (ulValue != 0)//通知任务来处理数据，没有RTOS可以用Flag代替	
	{
		
//		xTaskNotifyFromISR( MsgHandleTaskHandle,
//							ulValue,
//							eSetBits,
//		                	&xHigherPriorityTaskWoken); 
	}
//	portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
}
